{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "\n",
      "False\n",
      "False\n",
      "False\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "# 5.1\n",
    "car = \"A\"\n",
    "print(car == \"A\")\n",
    "\n",
    "print()\n",
    "print(car == \"A \")\n",
    "print(car == \"C\")\n",
    "print(car == \" A\\n\")\n",
    "print(car == \"A\\t\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "\n",
      "True\n",
      "\n",
      "False\n",
      "True\n",
      "False\n",
      "True\n",
      "False\n",
      "\n",
      "4\n",
      "\n",
      "False\n",
      "True\n",
      "\n",
      "False\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "# 5.2\n",
    "print(\"Abcd\" == \"abcd\")\n",
    "print()\n",
    "\n",
    "print(\"Abcd\".lower() == \"abcd\")\n",
    "print()\n",
    "\n",
    "print(1 == 3)\n",
    "print(7 <  8)\n",
    "print(8 > 10)\n",
    "print(3 <= 3)\n",
    "print(4 >= 7)\n",
    "print()\n",
    "\n",
    "print(not 1 or 2 and 3 and 0 or 4)\n",
    "print()\n",
    "\n",
    "lst = [\"A\", \"B\", \"C\"]\n",
    "print(\"a\" in lst)\n",
    "print(\"A\" in lst)\n",
    "print()\n",
    "\n",
    "print(\"C\" not in lst)\n",
    "print(\"c\" not in lst)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5分\n"
     ]
    }
   ],
   "source": [
    "# 5.3\n",
    "alien_color = \"green\"\n",
    "if alien_color == \"green\":\n",
    "    print(\"5分\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10分\n"
     ]
    }
   ],
   "source": [
    "# 5.4\n",
    "alien_color = \"green\"\n",
    "if alien_color == \"red\":\n",
    "    print(\"5分\")\n",
    "else:\n",
    "    print(\"10分\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "15分\n"
     ]
    }
   ],
   "source": [
    "# 5.5\n",
    "alien_color = \"red\"\n",
    "if alien_color == \"green\":\n",
    "    print(\"5分\")\n",
    "elif alien_color == \"yellow\":\n",
    "    print(\"10分\")\n",
    "else:\n",
    "    print(\"15分\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "中青年人\n"
     ]
    }
   ],
   "source": [
    "# 5.6\n",
    "age = int(input())\n",
    "if age < 2:\n",
    "    print(\"婴儿\")\n",
    "elif age < 4:\n",
    "    print(\"幼儿\")\n",
    "elif age < 13:\n",
    "    print(\"儿童\")\n",
    "elif age < 18:\n",
    "    print(\"少年\")\n",
    "elif age < 65:\n",
    "    print(\"中青年人\")\n",
    "else:\n",
    "    print(\"老年人\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "You really like apples\n"
     ]
    }
   ],
   "source": [
    "# 5.7\n",
    "favorite_fruits = [\"apple\", \"banana\"]\n",
    "if \"apple\" in favorite_fruits:\n",
    "    print(\"You really like apples\")\n",
    "if \"orange\" in favorite_fruits:\n",
    "    print(\"You really like oranges\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello admin, would you like to see a status report?\n",
      "Hello A, thank you for logging in again.\n",
      "Hello Lina, thank you for logging in again.\n",
      "Hello Joy, thank you for logging in again.\n",
      "Hello python, thank you for logging in again.\n",
      "Hello Jane, thank you for logging in again.\n"
     ]
    }
   ],
   "source": [
    "# 5.8\n",
    "users_lst = [\"admin\", \"A\", \"Lina\", \"Joy\", \"python\", \"Jane\"]\n",
    "\n",
    "for user_name in users_lst:\n",
    "    if \"admin\" == user_name:\n",
    "        print(\"Hello admin, would you like to see a status report?\")\n",
    "    else:\n",
    "        print(f\"Hello {user_name}, thank you for logging in again.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "We need to find some users!\n"
     ]
    }
   ],
   "source": [
    "# 5.9\n",
    "users_lst = []\n",
    "\n",
    "if users_lst:\n",
    "    for user_name in users_lst:\n",
    "        if \"admin\" == user_name:\n",
    "            print(\"Hello admin, would you like to see a status report?\")\n",
    "        else:\n",
    "            print(f\"Hello {user_name}, thank you for logging in again.\")\n",
    "else:\n",
    "    print(\"We need to find some users!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The user name has been used.\n",
      "The user name has been used.\n",
      "The user name has not been used.\n",
      "The user name has been used.\n",
      "The user name has not been used.\n",
      "['ADMIN', 'A', 'JOHN', 'LOG']\n"
     ]
    }
   ],
   "source": [
    "# 5.10\n",
    "current_users = (\"admin\", \"A\", \"JoHn\", \"Log\")\n",
    "current_users2 = []\n",
    "for name in current_users:\n",
    "    current_users2.append(name.upper())\n",
    "\n",
    "new_user = [\"a\",\"ADMIN\", \"lo\", \"log\", \"Jane\"]\n",
    "for name in new_user:\n",
    "    if name.upper() in current_users2:\n",
    "        print(\"The user name has been used.\")\n",
    "    else:\n",
    "        print(\"The user name has not been used.\")\n",
    "\n",
    "print(current_users2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1st\n",
      "2nd\n",
      "3rd\n",
      "4th\n",
      "5th\n",
      "6th\n",
      "7th\n",
      "8th\n",
      "9th\n"
     ]
    }
   ],
   "source": [
    "# 5.11\n",
    "num_lst = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n",
    "for i in num_lst:\n",
    "    if i == 1:\n",
    "        print(\"1st\")\n",
    "    elif i == 2:\n",
    "        print(\"2nd\")\n",
    "    elif i == 3:\n",
    "        print(\"3rd\")\n",
    "    else:\n",
    "        print(str(i) + \"th\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
